import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render, formattingMin } from '/@/utils/common/renderUtils';
//列表数据
export const columns : BasicColumn[] = [
	{
		title: '创建时间',
		align: "center",
		dataIndex: 'createtime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '是否可用',
		align: "center",
		dataIndex: 'trash',
		customRender: ({ text }) => {
			if (text == "true") {
				return '否'
			} else {
				return '是'
			}
		}
	},
	{
		title: '座位级别',
		align: "center",
		dataIndex: 'leveltype_dictText'
	},
	{
		title: '游玩天数',
		align: "center",
		sorter: true,
		dataIndex: 'daynum'
	},
	{
		title: '拼车费用',
		align: "center",
		dataIndex: 'price'
	},
	{
		title: '拼车最少人数',
		align: "center",
		dataIndex: 'extinfor',
		customRender: ({ text }) => {
			if (text) {
				let o = JSON.parse(text)
				return o.leastUserNum
			}
		}
	},
	{
		title: '最多可坐游客',
		align: "center",
		dataIndex: 'extinfor',
		customRender: ({ text }) => {
			if (text) {
				let o = JSON.parse(text)
				return o.bigUserNum
			}
		}
	},
	{
		title: '包车费用',
		align: "center",
		dataIndex: 'extinfor',
		customRender: ({ text }) => {
			if (text) {
				let o = JSON.parse(text)
				return o.charterPrice
			}
		}
	},

	{
		title: '座位标题',
		align: "center",
		dataIndex: 'leveltitle'
	},
	{
		title: '图片',
		align: "center",
		dataIndex: 'images',
		customRender: render.renderImage,
	},
	/*  {
	   title: '其他信息',
	   align:"center",
	   dataIndex: 'extinfor'
	  }, */
];
//查询数据
export const searchFormSchema : FormSchema[] = [
];
//表单数据
export const formSchema : FormSchema[] = [
	/*  {
		label: 'trash',
		field: 'trash',
		component: 'Input',
		dynamicRules: ({model,schema}) => {
			  return [
					 { required: true, message: '请输入trash!'},
			  ];
		 },
	  }, */
	{
		label: '座位车辆级别',
		field: 'leveltype',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "carTypeLeavel"
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请选择车辆座位级别!' },
			];
		},
		//dynamicDisabled: true
	},
	{
		label: '游玩天数',
		field: 'daynum',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入游玩天数!' },
				{ pattern: /^-?\d+$/, message: '请输入整数!' },
			];
		},
	},
	{
		label: '拼车费用',
		field: 'price',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入对应费用!' },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
	{
		label: '拼车最低人数',
		field: 'leastUserNum',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入拼车最低人数!' },
			];
		},
	},
	{
		label: '最大可坐游客',
		field: 'bigUserNum',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入最大可坐游客!' },
			];
		},
	},
	{
		label: '包车费用',
		field: 'charterPrice',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入对应费用!' },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
	/*  {
		label: '创建时间',
		field: 'createtime',
		component: 'InputNumber',
		dynamicRules: ({model,schema}) => {
			  return [
					 { required: true, message: '请输入创建时间!'},
			  ];
		 },
	  }, */
	{
		label: '座位标题',
		field: 'leveltitle',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入座位标题!' },
			];
		},
	},
	{
		label: '图片',
		field: 'images',
		component: 'JImageUpload',
		componentProps: {
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入图片!' },
			];
		},
	},
	{
		label: '详情',
		field: 'msg',
		component: 'JEditor',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入详细信息!' },
			];
		},
	},
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData) : FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}